<?php
use \yii\helpers\Url;
use \yii\helpers\Html;
use \common\models\Catalog;
use \common\models\Post;
use \common\models\Banner;
use \common\models\Links;
use yii\widgets\ListView;
use yii\bootstrap\BootstrapAsset;
use yii\web\JqueryAsset;
?><!--catalog-->
<!--/* @description 产品列表 */-->

<?php
$models=$dataProvider->getModels();
$pagination=$dataProvider->getPagination();
$pages=$pagination->getPageCount();
$curr_page=$pagination->getPage()+1;//当前页
$alias=Yii::$app->view->params['alias'];
?>


<?php
$photos = Banner::photos('首页');
if($alias=='supermarket'){
    $photos = Banner::photos('便利店&超市');
}
else if($alias=='pharmacy'){
    $photos = Banner::photos('药店');
}
else if($alias=='maternal'){
    $photos = Banner::photos('母婴店');
}
else if($alias=='cosmetics'){
    $photos = Banner::photos('化妆品');
}
else if($alias=='cashier'){
    $photos = Banner::photos('收银台&烟酒台');
}
else if($alias=='shelves'){
    $photos = Banner::photos('钢木货架');
}
else if($alias=='case'){
    $photos = Banner::photos('卖场配件');
}
?>
<script>
    var pages=Number('<?=$pages?>');
    var curr_page=Number('<?=$curr_page?>');
    <?php if($alias){?>
    list=<?=$page_size?>;
    paging=20;
    <?php }?>
</script>
<div  class="banner">
    <div class="hd">
        <ul>
            <?php if(count($photos)>1){?>
            <?php foreach ($photos as $photo){?>
                <li></li>
            <?php }?>
            <?php }?>
        </ul>
    </div>
    <div class="bd">
        <ul>
            <?php foreach ($photos as $photo){?>
                <li><a href="<?=$photo['url']?$photo['url']:'#'?>"><img src="<?=$photo['src']?>" /></a></li>
            <?php }?>
        </ul>
    </div>
    <a class="prev" href="javascript:void(0)"></a>
    <a class="next" href="javascript:void(0)"></a>
</div>
    <script type="text/javascript">
        jQuery(".banner").slide({mainCell:".bd ul",autoPlay:true,effect:"fold",interTime:"2500"});
    </script>
<!--    <div class="online_box" style="top:733px;">-->
<!--        <img src="images/online.png">-->
<!--        <div>-->
<!--            <p><img src="images/online_contact.png"><span>科牌-小燕</span></p>-->
<!--            <p><img src="images/online_contact.png"><span>科牌-小燕</span></p>-->
<!--        </div>-->
<!--    </div>-->
    <div class="content wrapper">
        <div class="content_box">
            <div class="product_display clearfix">
                <?=$this->render('/public/product');?>
                <?php if($pages){?>
                <div class="clearfix"></div>
                <div class="page_box clearfix">
                    <a class="prev" href="javascript:;">上一页</a>
                    <span>
                        <?php $a=0; for($i=1;$i<=$pages;$i++){?>
                            <a class="<?=$i==$curr_page?'on':''?>" href="javascript:;"><?=$i?></a>
                        <?php $a++;if($a==2){
                            break;
                            }}?>
                    </span>
                    <a class="next" href="javascript:;">下一页</a>
                </div>
                <script>
                    pageGroup(curr_page,pages);
                    $(document).on('click',".page_box span a",function () {
                        var index=Number($(this).text());
                        pageGroup(index,pages);
                        getProduct('<?=Url::toRoute('base/ajax-product')?>','<?=$alias?>',index);
                    });
                    $(document).on('click','.prev',function () {
                        var index=Number($(".page_box span .on").text());
                        pageUp(index,pages);
                        index=Number($(".page_box span .on").text());
                        getProduct('<?=Url::toRoute('base/ajax-product')?>','<?=$alias?>',index);
                    });
                    $(document).on('click','.next',function () {
                        var index=Number($(".page_box span .on").text());
                        pageDown(index,pages);
                        index=Number($(".page_box span .on").text());
                        getProduct('<?=Url::toRoute('base/ajax-product')?>','<?=$alias?>',index);
                    });
//                    $(".page_box span a").click(function(){
//                        var index=Number($(this).text());
//                        pageGroup(index,pages);
//                        //$(this).addClass("on").siblings().removeClass("on");
//                    })
                </script>
                <?php }?>
            </div>
        </div>
    </div>
